package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.UserDao;
import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    public boolean save(User user) {
        return userDao.save(user);
    }

    public boolean update(User user) {
        return userDao.update(user);
    }

    public boolean delete(Integer uuid) {
        return userDao.delete(uuid);
    }

    public User findById(Integer uuid) {
        return userDao.findById(uuid);
    }

    public PageInfo<User> findAll(int page,int size) {
        Page<User> startPage = PageHelper.startPage(page, size);
        List<User> user = userDao.findAll();
        return new PageInfo<User>(user);
    }

    public User login(String username, String password) {
        return userDao.findByUsernameAndPassword(username,password);
    }
}
